import React, { Component } from 'react';
import { connect } from 'react-redux'
import { addGun,removeGun,addGunAsync } from './index.redux'

class App extends Component {
    render() {
      const {num,addGun,removeGun,addGunAsync} = this.props
      return (
        <div>
          <p>现在有武器{num}把</p>
          <button onClick={addGun}>申请武器</button>
          <button onClick={removeGun}>上交武器</button>
          <button onClick={addGunAsync}>拖两天再给</button>
        </div>
      )
    }
}

const mapStateToProps = (state) => {
  return {
    num: state
  }
}

const actionCreators = {
  addGun,
  removeGun,
  addGunAsync,
} 

App = connect(mapStateToProps,actionCreators)(App) 
export default App;
